package com.xrui.hbase.codec;


import com.xrui.hbase.impl.BoundColumnReaderSpec;
import com.xrui.hbase.schema.TableLayout;
import com.xrui.hbase.schema.spec.CellSpec;

import java.io.IOException;

/** Interface for factories of CellDecoder instances. */
public interface CellDecoderFactory {
  /**
   * Creates a new cell decoder.
   *
   * @param cellSpec Specification of the cell encoding.
   * @return a new cell decoder.
   * @throws IOException on I/O error.
   *
   * @param <T> Type of the value to decode.
   */
  <T> CellDecoder<T> create(CellSpec cellSpec) throws IOException;

  /**
   * Creates a new cell decoder.
   *
   * @param layout TableLayout from which to retrieve storage information.
   * @param spec Specification of the cell encoding.
   * @return a new cell decoder.
   * @throws IOException on I/O error.
   *
   * @param <T> Type of the value to decode.
   */
  <T> CellDecoder<T> create(TableLayout layout, BoundColumnReaderSpec spec)
      throws IOException;
}
